using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_RSS_AddRss : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
            BindData();
    }
    private void BindData()
    {
        if (Request.QueryString["RssId"] != "" && Request.QueryString["RssId"]!=null)
        {
            PccMsg msg = new PccMsg();
            msg.CreateFirstNode("RssId", Request.QueryString["RssId"]);
            msg.CreateFirstNode("Title", "");
            msg.CreateFirstNode("Link", "");
            msg.CreateFirstNode("ShowMK", "");

            clsWebShop cls = new clsWebShop();
            DataTable  dt = null;
            dt = cls.Get_RssByCondition(msg.GetXmlStr).Tables[0];
            if (dt.Rows.Count > 0)
            {
                txtWebPage.Text = dt.Rows[0]["Title"].ToString();
                txtlink.Text = dt.Rows[0]["Link"].ToString();
                if (dt.Rows[0]["ShowMK"].ToString() == "Y")
                    chkCheck.Checked = true;
                else
                    chkCheck.Checked = false;
            }
        }
    }
    private void ReturnPage()
    {
        Response.Redirect("Rss.aspx?CodeID=" + Request.QueryString["CodeID"]);
    }
    protected void btnAdd_Catalogue_Click(object sender, EventArgs e)
    {
        PccMsg msg = new PccMsg();
        string state = "N";
        if (chkCheck.Checked == true)
            state = "Y";
        string RssId="0";
        if (Request.QueryString["RssId"] != "" && Request.QueryString["RssId"] != null)
            RssId = Request.QueryString["RssId"];
        msg.CreateFirstNode("RssId", RssId);
        msg.CreateFirstNode("Title", txtWebPage.Text.Trim());
        msg.CreateFirstNode("Link", txtlink.Text.Trim());
        msg.CreateFirstNode("ShowMK", state);
        msg.CreateFirstNode("Status", "N");
        msg.CreateFirstNode("UpdID", Session["AdminUserID"].ToString());


        clsWebShop cls = new clsWebShop();
        cls.Ins_Upd_Rss(msg.GetXmlStr.ToString());
        ReturnPage();
    }
    protected void btnReturn_Click(object sender, EventArgs e)
    {
        ReturnPage();
    }
}
